﻿/*文件注释
 * ===============================================================================
 * 说明：
 * 作者：曾永佑
 * 版本：V1.0
 * 创建日期：2013-03-10
 * 完成日期： 
 * 修改纪录：  
 * ===============================================================================
 */  
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Principal;
using SRF.Security.Principal;
using SRF.Security.Permission;

namespace SRF.Security
{
    /// <summary>
    /// 安全认证提供程序
    /// </summary>
    public interface ISecurityProvider
    {
        /// <summary>
        /// 获取当前用户信息
        /// </summary>
        /// <returns>返回当前用户信息</returns>
        IUser GetCurrentUser();
        /// <summary>
        /// 根据用户名获取用户信息
        /// </summary>
        /// <param name="loginId">登录名</param>
        /// <returns>返回用户信息</returns>
        IUser GetUser(string loginId);
        /// <summary>
        /// 修改密码
        /// </summary>
        /// <param name="loginId">登录名</param>
        /// <param name="newPassword">密码</param>
        /// <param name="oldPassword">旧密码</param>
        void ChangePassword(string loginId, string newPassword, string oldPassword = "");
        /// <summary>
        /// 
        /// </summary>
        /// <param name="loginId"></param>
        /// <param name="password"></param>
        /// <param name="code"></param>
        void Login(string loginId = "", string password = "", string code = "");
        /// <summary>
        /// 用户登出
        /// </summary>
        void Logout();
         
        /// <summary>
        /// 当前是否有某项操作权限
        /// </summary>
        /// <param name="action">操作编码</param>
        /// <returns></returns>
        bool HasActionGrant(string action);

        /// <summary>
        /// 当前是否有访问某个url的权限
        /// url为空时，检测当前url
        /// </summary>
        /// <param name="url">要检测的url</param>
        /// <returns></returns>
        bool HasUrlGrant(string url = "");
        /// <summary>
        /// 获取数据规则过滤条件
        /// </summary>
        /// <param name="code">数据规则编码</param>
        /// <returns></returns>
        string GetDataRuleCondition(string code);

        /// <summary>
        /// 用户是否是登录状态
        /// </summary>
        bool IsLogin { get; }
    }
}